namespace Domotica.Media
{
    using System;
    using System.Collections.Generic;

    public class Artist : IComparable<Artist>
    {
        private DictionaryCollection<string, Album> _albums = new DictionaryCollection<string, Album>();
        private string _name;
        private string _SortName;

        public Artist(string name)
        {
            if (name == "")
            {
                name = "(Unknown)";
            }
            this._name = name;
            this._SortName = GetSortName(name);
        }

        public int CompareTo(Artist other)
        {
            return Comparer<string>.Default.Compare(this.SortName, other.SortName);
        }

        public static string GetSortName(string name)
        {
            if (name.StartsWith("The "))
            {
                return name.Substring(4).ToLower();
            }
            return name.ToLower();
        }

        public override string ToString()
        {
            return this.Name;
        }

        public DictionaryCollection<string, Album> Albums
        {
            get
            {
                return this._albums;
            }
        }

        public string Name
        {
            get
            {
                return this._name;
            }
        }

        public string SortName
        {
            get
            {
                return this._SortName;
            }
        }
    }
}

